<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>固定定位</title>
    <!-- 重点： position: fixed;
            /* 走浏览器的一半 */
            left: 50%;
            margin-left: 400px; -->
    <style>
        .w {
           width: 800px;
           height: 20000px;
           margin: 100px auto;
           background-color: pink;
        }
        .fixed {
            position: fixed;
            /* 走浏览器的一半 */
            left: 50%;
            margin-left: 400px;
            width: 50px;
            height: 100px;
            background-color: red;
        }
    </style>
</head>
<body>
    <div class="fixed"></div>
    <div class="w">版心</div>
</body>
</html>